/*
 * @Description: 原型链继承
 * @Author: zzj
 * @Date: 2021-09-06 14:06:23
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-06 14:06:24
 */

function Animal (name, age) {
  this.name = name;
  this.age = age;
}
Animal.prototype.sayName = function () {
  console.log("my name is", this.name)
}

function Bird () { }
Bird.prototype = new Animal()
Bird.prototype.constructor = Bird

function Person (name, age, gender) {
  this.name = name;
  this.age = age;
  this.gender = gender;
}

Person.prototype = new Animal()
Person.prototype.constructor = Person

Person.prototype.sayAge = function () {
  console.log("my age is ", this.age)
}

var p = new Person("terry", 12, "male")
console.log(p)

p.sayAge()
p.sayName()

console.log(p instanceof Person)
console.log(p instanceof Animal)
console.log(p instanceof Object)
console.log(p instanceof Bird)